package mt.tratapedidos;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.ServerSocket;
import java.net.Socket;

import mt.comm.ServerSideMessage.Type;
import mt.dummy.ServerCommDummy;


public class TrataPedidosServidorDummy extends Thread {
	
	private ObjectInputStream socketIn;
	private ObjectOutputStream socketOut;
	private ServerSocket serversocket;
	private Socket socket;
	private ServerCommDummy serverCommDummy;
	private static final int PORTO=8080;

	
	


	public TrataPedidosServidorDummy(ServerCommDummy serverCommDummy) {
		this.serverCommDummy=serverCommDummy;
		
	}



	



	public void run(){
		
		try {
			serversocket= new ServerSocket(PORTO);
			System.out.println("Servidor iniciado..." + PORTO);
			
		
			while(true){
		
				
				
				socket= serversocket.accept();
				
				 socketOut = new ObjectOutputStream(socket.getOutputStream());
				 socketIn= new ObjectInputStream(socket.getInputStream());
				 
				 new TrataPedidos(serverCommDummy,socketIn,socketOut).start();
			}
				
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
			
		}

}